<template>
    <div class="main">
        <i class="iconfont icon-jilu"></i>
        <textarea v-model="msg" placeholder="请输入您的反馈意见或投诉建议" cols="30" rows="10"></textarea>
        <h1></h1>
        <van-button type="primary" @click="submit" class="mybtn" size="large">提交反馈</van-button>
        <div class="tel">
            <div class="left">
                <a @click="phonecall(tel,`意见反馈`)"><i class="iconfont icon-dianhua"></i>意见反馈</a>
            </div>
            <div class="right">
                <a @click="phonecall(tel,`投诉电话`)"><i class="iconfont icon-dianhua"></i>投诉电话</a>
            </div>
        </div>
    </div>
</template>

<script>
    import api from '@/api/api';
    import {
        Dialog,
        Toast
    } from 'vant';
    export default {
        data() {
            return {
                msg: '',
                tel: '051258732888'
            }
        },
        methods: {
            submit() {
                if (this.msg.length < 10) {
                    Toast.fail('请输入至少10个字');
                    return;
                } else if (this.msg.length > 500) {
                    Toast.fail('请输入少于500个字');
                    return;
                }
                let data = {
                    EntID: this.$store.state.userInfo.EntID,
                    EntName: this.$store.state.userInfo.EntName,
                    UserName: this.$store.state.userInfo.XM,
                    UserID: this.$store.state.userInfo.ID,
                    OpenID: this.$store.state.userInfo.OpenID,
                    Opinion: this.msg
                };
                api.addComplain(data).then(re => {
                    if (re.success == true) {
                        Toast.success('提交成功,谢谢您的建议！');
                    }
                })
            },
            phonecall(no,logType) {
                window.location.href = 'tel://' + no;
                // let data = {
                //     EntID: this.$store.state.userInfo.EntID,
                //     EntName: this.$store.state.userInfo.EntName,
                //     UserName: this.$store.state.userInfo.XM,
                //     UserID: this.$store.state.userInfo.ID,
                //     OpenID: this.$store.state.userInfo.OpenID,
                //     LogType:logType
                // };
                // api.addPhoneLog(data);
                // return false;
            }
        },
    }
</script>

<style scoped lang='less'>
    .main {
        background: #fff;
        position: relative;
        >i {
            color: #2cb98e;
            position: absolute;
            top: 1em;
            left: 1em;
        }
        textarea {
            border: none;
            padding: 1em;
        }
        h1 {
            border-bottom: 1px solid #f0f0f0;
        }
        .mybtn {
            background: #2cb98e;
            width: 90%;
        }
        .tel {
            margin-top: 1em;
            padding: 1em;
            height: 3em;
            color: #2cb98e;
            letter-spacing: 0.1em;
            .left {
                float: left;
                a {
                    color: #2cb98e;
                }
            }
            .right {
                float: right;
                a {
                    color: #2cb98e;
                }
            }
        }
    }
</style>